package com.ws.service.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ws.bean.Customer;
import com.ws.bean.MaintenanceRecord;
import com.ws.bean.RenralOrder;
import com.ws.bean.ReturnCheck;
import com.ws.bean.Staff;
import com.ws.bean.Vehicle;
import com.ws.bean.VehicleCount;
import com.ws.bean.VehicoleBrand;
import com.ws.dao.RenralOrderDao;
import com.ws.service.RenralOrderService;
import com.ws.util.Page;
@Service
public class RenralOrderServiceImp implements RenralOrderService {
	@Autowired
	RenralOrderDao dao;
	@Override
	public List<RenralOrder> getOrders(Customer customer, Page page) {
		
		return dao.getOrders(customer,page);
	}
	@Override
	public int getCount(Customer customer) {
		return dao.getCount(customer);
	}
	@Override
	public int addOrder(RenralOrder order) {
		return dao.addOrder(order);
	}
	@Override
	public int delOrder(Integer id) {
		return dao.delOrder(id);
	}
	@Override
	public int editOrder(RenralOrder order) {
		return dao.editOrder(order);
	}
	@Override
	public List<Customer> getCustomers() {
		return dao.getCustomers();
	}
	@Override
	public List<VehicoleBrand> getBrands() {
		return dao.getBrands();
	}
	@Override
	public List<Vehicle> getModelByID(Integer id) {
		return dao.getModelByID(id);
	}
	@Override
	public List<Vehicle> getPlateNum(String model) {
		return dao.getPlateNum(model);
	}
	@Override
	public int checkOrder(RenralOrder order) {
		ReturnCheck check = dao.getCheck(order);
		System.out.println("check的值");
		System.out.println(check.getId());
		MaintenanceRecord tenance = dao.getTenance(check.getId());
		System.out.println(check.getStatus());
		System.out.println(tenance.getStatus());
		if(check.getStatus().equals("已完成") && tenance.getStatus().equals("已完成")) {
			return 1;
		}
		return -1;
	}
	/**
	 * 车辆每次被租出去的时候count++
	 */
	@Override
	public int vehicleJia(RenralOrder order) {
		return dao.vehicleJia(order);
	}
	/**
	 * 获取车辆表里面的count 
	 */
	@Override
	public List<VehicleCount> getVehicleCount() {
		return dao.getVehicleCount();
	}
	/**
	 * 获取车辆的名字
	 */
	@Override
	public List<String> getVehicleName() {
		return dao.getVehicleNamee();
	}
	@Override
	public List<Staff> getStaff() {
		return dao.getStaff();
	}

}
